package io.renren.modules.bike.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.modules.bike.entity.MoneyEntity;
import io.renren.modules.bike.service.MoneyService;
import io.renren.modules.bike.service.impl.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Map;

@RestController
public class PayController {



    @Autowired
    PayService payService;

    @Autowired
    MoneyService moneyService;

    @PostMapping("/bike/toCZhi")
    public Object toBuy(@RequestBody MoneyEntity money) throws Exception {
        System.out.println(money);
//        moneyService.update(money);
//        JSONObject jsonObject = new JSONObject();
//        if (order != 0) {
//            jsonObject.put("code", 1);
//            jsonObject.put("order", order);
//            jsonObject.put("msg", "购票成功!");
//        } else {
//            jsonObject.put("code", 0);
//            jsonObject.put("msg", "购票失败!");
//        }
//        return jsonObject;
        return payService.pay(money);
    }

    @GetMapping(value = "/bike/userCZhi", produces = {"text/html;charset=UTF-8"})
    public Object returnUrl(@RequestBody MoneyEntity money,HttpServletRequest request) throws Exception {

        return payService.pay(money);
    }
}
